package com.lecture.javamode.mode.builder;

import lombok.Getter;

/**
 * @author luyn
 * @version 1.0
 * @description
 * @date 2022/2/8 17:23
 */
@Getter
public class ResourcePoolConfig {
    
    private String name;
    private int maxTotal;
    private int maxIdle;
    private int minIdle;

    private ResourcePoolConfig(Builder builder) {
        this.name = builder.name;
        this.maxTotal = builder.maxTotal;
        this.maxIdle = builder.maxIdle;
        this.minIdle = builder.minIdle;
    }

    public static class Builder {
        private String name;
        private int maxTotal;
        private int maxIdle;
        private int minIdle;


        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder maxTotal(int maxTotal) {
            this.maxTotal = maxTotal;
            return this;
        }

        public Builder maxIdle(int maxIdle) {
            this.maxIdle = maxIdle;
            return this;
        }

        public Builder minIdle(int minIdle) {
            this.minIdle = minIdle;
            return this;
        }

        public ResourcePoolConfig build() {
            return new ResourcePoolConfig(this);
        }
    }


    public static void main(String[] args) {
        ResourcePoolConfig resourcePoolConfig = new Builder().name("mysql").build();
        System.out.println(resourcePoolConfig.getName());
    }

}
